package zhuzx.solution.ir;

import java.util.List;

import org.zhuzx.util.GeneralUtil;
import org.zhuzx.util.JdbcUtil;
import org.zhuzx.util.ListDataUtil;

public class IrTempVerifier {
	
	public static void main(String[] args) {
		String[] orgNames = {
				"研发中心",
//				"华新环境工程(武穴)有限公司",
//				"华新环境工程（黄石）有限公司",
//				"华新红塔水泥(景洪)有限公司",
//				"项目管理&工程"
		};
		String dateStart = "2020-02-07";
		String dateEnd = "2020-02-08";
		
		for (String orgName : orgNames) {
			verifier(orgName, dateStart, dateEnd);
		}
	}
	
	private static void verifier(String orgName, String dateStart, String dateEnd) {
		String sql = "select distinct t.phone_number from OA.IR_ADDRESS_BOOK t where 1=1";
		sql += IrDataHelper.createOrgExp("t.qywx_org_name", orgName);
		List<String> phoneList = ListDataUtil.getValues(JdbcUtil.executeQuery(sql), "PHONE_NUMBER");
		sql = "select count(distinct t.phone_number) as CNUM from oa.ir_clock_in_info t\n" +
				"where t.create_date > '%s' and t.create_date < '%s'\n" +
				"and t.phone_number in('" + GeneralUtil.getCombinedString(phoneList, "','") + "')";
		sql = String.format(sql, dateStart, dateEnd);
		int count = Integer.parseInt(JdbcUtil.executeQuery(sql).get(0).get("CNUM"));
		System.out.println(String.format("%s\n\t\t总人数为：%s\t\t%s的打卡人数为：%s",
				orgName, phoneList.size(), dateStart, count));
	}

}